package sdau.hjk.dao;

import sdau.hjk.entity.UserReport;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 *@version 1.0
 *@author: huangjiakai
 *@create:2021−02-22 14:02
 *@className:com.hjk.dao.IUserReportDao
 *@description: TODO
 */
@Repository
public interface IUserReportDao {
    //根据id查询报备记录
    @Select("select * from report where id = #{id} order by date desc")
    public List<UserReport> findById(Integer id);
    //添加报备记录
    @Insert("insert into report(id,date,duration,destination,reason,approve) values(#{id},#{date},#{duration},#{destination},#{reason},#{approve})")
    public void saveUserReport(UserReport userReport);
    //查询报备记录
    @Select("select * from user_report where approve = '未审核' order by date desc")
    public List<UserReport> findAllReport();
    //审批报备记录
    @Update("update report set approve = '已通过' where id = #{id} and duration = #{duration}")
    public void approveUserReport(UserReport userReport);
}
